package com.docker.sys.permission;

import com.docker.core.constant.MainConstant;
import com.docker.core.mvc.dao.BaseDao;
import com.jfinal.kit.Okv;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * @Author ldl
 * @Create 2020/09/18 018 15:18
 */
public class PermissionDao extends BaseDao {

    @Override
    protected String getDbName() {
        return MainConstant.DB_DOCKER;
    }

    @Override
    protected String getSqlTplNameSpace() {
        return "sys.permission";
    }

    public void delete(String permId) {
        tplDelete("delete", permId);
    }

    public List<Record> list(Okv cond) {
        return tplSPList("list.normal", cond);
    }

    public boolean save(Record dbPerm) {
        return save("sys_permission", "perm_id", dbPerm);
    }

    public void update(String permName, String controller, String controllerName,
                       String appId, String actionKey) {
        tplUpdate("update", permName, controller, controllerName, appId, actionKey);
    }

    public List<Record> authList(Okv cond) {
        return tplSPList("list.auth", cond);
    }

}
